package com.fusion.service.impl;

import java.util.Date;
import java.util.UUID;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fusion.dao.UserMapper;
import com.fusion.domain.User;
import com.fusion.service.UserService;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService{

	@Override
	public boolean add() {
		User user = new User();
		user.setUserName(UUID.randomUUID().toString());
		user.setAge(UUID.randomUUID().toString());
		user.setCreateDate(new Date());
		user.setUpdateDate(new Date());
		boolean save = this.save(user);
		int c=1/0;
		System.out.println(c);
		return save;
	}

	@Override
	public IPage<User> findList() {
		QueryWrapper<User> queryWrapper = new QueryWrapper<>();
		LambdaQueryWrapper<User> lambda = queryWrapper.lambda();
		lambda.isNotNull(User::getId);
		lambda.orderByDesc(User::getCreateDate);
		return this.page(new Page<>(1,3), queryWrapper);
	}

}
